var yuyue=({

	/** 初始化房子信息 */
	loadHouseById : function(houseId){
		$.ajax({
			type: "POST",
			dataType: "json",
			url: "../house/getById.do?rnd="+ Math.random(),
			data: {
				'houseId':houseId
			},
			success: function(data){
				console.log(data)
				if( data.rows!=null ){
					$("#houseName").text(data.rows.houseName);
					$("#price").text(data.rows.price+"元/月");
					$("#floor").text(data.rows.floor);
				}else{
					$$.toast("或者房子信息失败");
				}
			},
			error: function(e) {
				$$.toast("请求出错");
			}
		});
	},

	/** 保存预约 */
	 saveAppointment : function (){
		var nickName = $("#nickName").val().trim();
		var sex = $("#sex").val();
		var phone = $("#phone").val().trim();
		var appointmentTime = $("#appointmentTime").val().trim();
		var userRemark = $("#userRemark").val().trim();
		var type = "1";
		var status = "1";
		
		if(isNull(nickName)){
			$$.toast("请输入姓名");
			return;
		}
		if(isNull(sex)){
			$$.toast("选择性别");
			return;
		}
		if(!checkPhone(phone)){
			$$.toast("请输入正确的手机号码");
			return;
		}
		if(isNull(appointmentTime)){
			$$.toast("请选择预约时间");
			return;
		}
		
		$$.showPreloader("处理中");
		$.ajax({
			type: "POST",
			dataType: "json",
			url: "../appointment/add.do?rnd="+ Math.random(),
			data: {
				'houseId':houseId,
				'nickName': nickName,
				'sex': sex,
				'phone': phone,
				'appointmentTime': appointmentTime,
				'userRemark': userRemark,
				'type': type,
				'status': status
			},
			success: function(data){
				$$.hidePreloader();
				console.log(data)
				if( data.resultCode=="0" ){
					$$.alert("预约成功", function(){
						window.history.go(-1);
					});
				}else{
					$$.toast("预约失败");
				}
			},
			error: function(e) {
				$$.hidePreloader();
				$$.toast("请求出错");
			}
		});
		
		
	}

})